package com.xs.action.dto;

import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/// 默认网络框架传输体
@Slf4j
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ProtobufClass
public class Message {
    /// 消息ID
    private String messageId;

    /// 路由
    public Integer route;

    /// 操作
    public Integer cmd;

    /// 0.proto 1.json
    public int type;

    /// 标识码
    private Integer code;

    /// 类名
    private String className;

    /// 消息
    private String message;

    /// json 数据结构体
    public List<Object> data = new ArrayList<>();

    /// 扩展字段
    public Map<String, Object> ext = new java.util.HashMap<>();

    /// 数据
    public Object dataByte;

    /// 获取fullRoute
    public int obtainFullRoute() {
        return route << 16 | cmd;
    }
}
